package com.geeksaga.dao.ibatis.oracle;


import java.util.Map;

import org.springframework.dao.DataAccessException;
import org.springframework.stereotype.Repository;

import com.geeksaga.dao.TableRowCountDao;
import com.geeksaga.dao.ibatis.BaseIBatisDao;
import com.geeksaga.domain.TableRowCount;

/**
 * @author newbie
 * @since 0.1
 */
@Repository
public class TableRowCountDaoImpl extends BaseIBatisDao implements TableRowCountDao {

    /* (non-Javadoc)
     * @see com.geeksaga.dao.TableRowCountDao#plusTotalCount(com.geeksaga.domain.TableRowCount)
     */
    public int plusTotalCount(TableRowCount tableRowCount) throws DataAccessException {
        return getSqlMapClientTemplate().update("TABLE_ROW_COUNT.plusTotalCount", tableRowCount);
    }
    
    /* (non-Javadoc)
     * @see com.geeksaga.dao.TableRowCountDao#plusDeleteCount(com.geeksaga.domain.TableRowCount)
     */
    public int plusDeleteCount(TableRowCount tableRowCount) throws DataAccessException {
        return getSqlMapClientTemplate().update("TABLE_ROW_COUNT.plusDeleteCount", tableRowCount);
    }
    
    /* (non-Javadoc)
     * @see com.geeksaga.dao.TableRowCountDao#minusTotalCount(com.geeksaga.domain.TableRowCount)
     */
    public int minusTotalCount(TableRowCount tableRowCount) throws DataAccessException {
        return getSqlMapClientTemplate().update("TABLE_ROW_COUNT.minusTotalCount", tableRowCount);
    }

    /* (non-Javadoc)
     * @see com.geeksaga.dao.TableRowCountDao#addTableRowCountDao(com.geeksaga.domain.TableRowCount)
     */
    public TableRowCount addTableRowCountDao(TableRowCount tableRowCount) throws DataAccessException {
        return (TableRowCount) getSqlMapClientTemplate().insert("TABLE_ROW_COUNT.addTableRowCount", tableRowCount);
    }
    
    /* (non-Javadoc)
     * @see com.geeksaga.dao.TableRowCountDao#count(java.util.Map)
     */
    public TableRowCount count(Map<String, Object> parameter, String table) throws DataAccessException {
        parameter.put("tableName", table);
        
        return (TableRowCount) getSqlMapClientTemplate().queryForObject("TABLE_ROW_COUNT.count", parameter);
    }   
}